
import 'package:flutter/material.dart';
import 'package:myapp/app/theme/app_color.dart';
import 'package:myapp/app/theme/resource/images.dart';
import 'package:myapp/app/utils/platform_utils.dart';
import 'package:myapp/app/widget/home_bottom_sheet.dart';

typedef TapCallback = void Function();


void _showBottomSheet(BuildContext context) {
  showModalBottomSheet(context: context, builder: (context) {
    return HomeBottomSheet();
  },backgroundColor: Colors.transparent);
}

class HomeBar extends AppBar {
  HomeBar({TapCallback? onTap})
      : super(
          backgroundColor: AppColor.red80,
          actions: [
            Container(
              margin: EdgeInsets.only(right: 5),
              padding: EdgeInsets.all(5),
              child: Builder(builder: (BuildContext context) {
                return InkWell(
                  child: Column(
                    children: [
                      Image.asset(
                        ImageKeys.bar_pub,
                        height: 24,
                        width: 24,
                      ),
                      Text(
                        "发布",
                        style: TextStyle(fontSize: 14, color: AppColor.white),
                      )
                    ],
                  ),
                  onTap: (){
                    if(onTap != null) {
                      onTap.call();
                      return;
                    }
                    _showBottomSheet(context);
                  },
                );
              }),
            )
          ],
          title: Container(
            padding: EdgeInsets.only(left: 15),
            margin: EdgeInsets.only(right: PlatformUtils.isIos ? 15 : 0),
            height: 40,
            width: double.infinity,
            decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: AppColor.white),
            child: Flex(direction: Axis.horizontal, children: [
              Image.asset(ImageKeys.icon_search, width: 20, height: 20,),
              Expanded(child: Padding(child: Text("日方回应金牌掉皮 | 上海警方通报钱枫", style: TextStyle(color: AppColor.hex_666, fontSize: 14),), padding: EdgeInsets.only(left: 8),))
            ],),
          ),
        );
}
